@extends('admin.base')
@section('title', '问答列表')
@section('content')
    <div class="layui-card">
        <fieldset class="layui-elem-field">
            <div class="layui-field-box">
            <span class="layui-breadcrumb" lay-separator=">>">
                <a class="layui-btn-sm" href="{{url('admin/type/index')}}" style="cursor:pointer;" ><cite>问答列表</cite></a>;
            </span>
            </div>
        </fieldset>
        <div class="layui-card-header">
            <div>
        <span class="pull-left">
          <div class="layui-form">
            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">关键字</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="sub_keywords" name="keywords" value="{{ isset($request->keywords) ? $request->keywords : '' }}"  placeholder="请输入相关问题">
                </div>
                <label class="layui-form-label" style="width:100px;">商品不存在</label>
                        <div class="layui-input-inline" style="width:130px;">
                            <select name="sub_exit" lay-verify="required">
                                <option value="3">请选择</option>
                                <option value="1" @if($request->is_exit == 1)selected @endif>是</option>
                                <option value="2" @if($request->is_exit == 2)selected @endif>否</option>

                            </select>
                        </div>
                {{--<label class="layui-form-label">商品ID</label>--}}
                {{--<div class="layui-input-inline">--}}
                    {{--<input type="text" class="layui-input" id="sub_gid" name="gid" value="{{ isset($request->gid) ? $request->gid : '' }}"  placeholder="请输入商品ID">--}}
                {{--</div>--}}
              </div>
            </div>
          </div>
        </span>
        <div class="layui-input-inline">
            <button class="layui-btn" lay-submit lay-filter="selectsub" style="margin-top:-10px">搜索</button>
        </div>

            <span class="pull-right">

            </span>
            </div>
        </div>

        <div class="layui-card-body">
            <style>
                table tr td.tc,table tr th.tc {
                    text-align: center;
                    cursor:default;
                }
            </style>
            <table class="layui-table" lay-even lay-size="">
                <colgroup>
                    <col width="">
                    <col width="">
                    <col width="">
                    <col width="">
                </colgroup>
                <thead>
                <tr>
                    <th class="tc">ID</th>
                    <th class="tc">商品ID</th>
                    <th class="tc">商品名称</th>
                    <th class="tc">问题</th>
                    <th class="tc">答案</th>
                    <th class="tc">创建时间</th>
                    <th class="tc">操作</th>
                </tr>
                <tbody>
                @if($list->isEmpty())
                    <tr>
                        <td colspan="7" class="tc">暂无数据</td>
                    </tr>
                @else
                    @foreach ($list as $v)
                        <tr>
                            <td class="tc">{{$v->id}}</td>
                            <td class="tc">{{$v->gid}}</td>
                            <td class="tc">{{$v->gname}}</td>
                            <td class="tc">{{ $v->question }}</td>
                            <td class="tc">
                                <textarea name="alipay_rsaPrivateKey" placeholder="请输入内容" class="layui-textarea" disabled>{{ $v->answer }}</textarea>
                            </td>

                            <td class="tc">{{ $v->created_at }}</td>
                        <td class="tc">
                            <div class="layui-btn-group" >
                                <button class="layui-btn layui-btn-sm" onclick="active('{{url('admin/shop/edit_q')}}','{{$v->id}}','编辑','800px','600px');" >编辑</button>
                                <button class="layui-btn layui-btn-sm layui-btn-danger" onclick="del('{{url('admin/shop/delete_qanda')}}','{{$v->id}}');" >删除</button>
                            </div>
                        </td>
                        </tr>
                    @endforeach
                @endif
                </tbody>
                </thead>
            </table>
            <!-- 分页 -->
            <div class="sabrosus" >{{ $page }}</div>
        <!-- {{$list->total()}} -->
        </div>

    </div>
@endsection
@section('js')
    <script>
        layui.use('form', function(){
            var form = layui.form;

            //搜索
            form.on('submit(selectsub)', function(data){
                let keywords = $('#sub_keywords').val();//关键字
                let gid = $('#sub_gid').val();//商品ID
                let is_exit = $("select[name=sub_exit]").val();//筛选
                location.href = "{{url('admin/shop/q_a_store')}}"+"?keywords="+keywords+'&is_exit='+is_exit;
                {{--location.href = "{{url('admin/shop/q_a_store')}}"+"?keywords="+keywords+'&gid='+gid;--}}
                return false;
            });

            //监听指定开关
            form.on('switch(switchTest)', function(data){
                var id = data.value;

                if(data.elem.checked){
                    var state = 1;//启用
                }else{
                    var state = 2;//禁用
                }
                ajax('/admin/user/up_state',{id:id,state:state});
            });
        });
    </script>
@endsection